﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DTO;
using BUS;
using System.Collections.Generic;

namespace WebSieuThi.ThuNgan.BanHangAjax
{
    public partial class taochitiethoadon : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int idmahang = int.Parse(Request.QueryString["idmahang"].ToString());
            int soluong = int.Parse(Request.QueryString["soluong"].ToString());
            int tongchitiet = int.Parse(Request.QueryString["tongchitiet"].ToString());
            
            ChiTietHoaDon ct = new ChiTietHoaDon();
            ct.DonGia = 0;
            ct.IdMaHH = idmahang;
            ct.SoLuong = soluong;
            ct.TongGiaTri = tongchitiet;

            HoaDon hd = new HoaDon();
            hd = HoaDonBUS.timhd();

        //    ct.HangHoa.MaHH

            string ma = HangHoaBUS.TimTheoId(idmahang).MaHH;

            bool b1 = HangHoaBUS.RutHangTrenQuay(soluong, ma);

            ct.IdMaHoaDon = hd.Id;




            ct.MaChiTietHD = "CT100";

            bool b = ChiTietHoaDonBUS.Them(ct);

            if (!b)
            {
                Response.Write("Xãy ra lỗi!");
            }
            else
                Response.Write("");
            

        }
    }
}
